import React from 'react';
import { connect } from 'dva'
import moment from 'moment'

import MyDatePicker from 'components/MyDatePicker'
import TopNavBar from 'components/TopNavBar';
import AnalysisTitle from 'components/AnalysisTitle';

import Indicators from './components/Indicators'
import Statistics from './components/Statistics'

const nowTimeStamp = Date.now();
const now = new Date(nowTimeStamp);
const time = moment(now).format('YYYY')

@connect(({ hotline }) => ({ ...hotline }))
class Hotline extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      time
    }
  }

  handleChange = (time) => {
    this.setState({
      time
    })
  }

  render() {
    const { props, state } = this;
    const { route } = props;
    const { time } = state;
    return (<>
      <TopNavBar title={route.title} />
      <Indicators />
      <AnalysisTitle />
      <MyDatePicker
        defaultValue={time}
        onChange={this.handleChange}
      />
      <Statistics
        defaultValue={time}
      />
    </>)
  }
}

export default Hotline;
